Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: support cloudflare pages functions #13

Merged
merged 4 commits into from
Jun 16, 2024
Merged

Conversation

EresDev
Copy link
Contributor

@EresDev EresDev commented Jun 5, 2024

Resolves #12

QA - static only project

The changes should be backward compatible. The existing static-only projects should keep working without requiring any change. I have used a fork of ubiquity/work.ubq.fi to test this.
workflow: https://github.com/EresDevOrg/work.ubq.fi-2/actions/runs/9423832718/job/25962973041
deployment: https://8f190d0e.work-ubq-fi-2.pages.dev/

QA - project with pages functions

It should deploy Cloudflare pages static files, and Cloudflare pages functions.

workflow: https://github.com/EresDevOrg/gift-card-pay.ubq.fi-2/actions/runs/9423625045/job/25962649398
deployment:

https://26f58827.gift-card-pay-ubq-fi-2.pages.dev/?claim=W3sidHlwZSI6ImVyYzIwLXBlcm1pdCIsInBlcm1pdCI6eyJwZXJtaXR0ZWQiOnsidG9rZW4iOiIweGU5MUQxNTNFMGI0MTUxOEEyQ2U4RGQzRDc5NDRGYTg2MzQ2M2E5N2QiLCJhbW91bnQiOiIyNzAwMDAwMDAwMDAwMDAwMDAwMCJ9LCJub25jZSI6IjgyMzk0MzE1NDk3NDc3Njk1MTUwOTA4NTM5OTU5MDAwNDUwOTA0NjI0MTMzNzkwMTEyMjY4NjI0NTI5MzMzNTkwMjM5NTA5NjA5Mzg2IiwiZGVhZGxpbmUiOiIxMTU3OTIwODkyMzczMTYxOTU0MjM1NzA5ODUwMDg2ODc5MDc4NTMyNjk5ODQ2NjU2NDA1NjQwMzk0NTc1ODQwMDc5MTMxMjk2Mzk5MzUifSwidHJhbnNmZXJEZXRhaWxzIjp7InRvIjoiMHhmMzlGZDZlNTFhYWQ4OEY2RjRjZTZhQjg4MjcyNzljZmZGYjkyMjY2IiwicmVxdWVzdGVkQW1vdW50IjoiMjc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3NWI0ODYyYzYwYjg2NWIyYzVkYTA5YzBiY2RjZWE4MzI1ZDZmNjg0Njk3NGQzMzQ2OTEyYmZmMzMyZmI2ODJiNGQzMjA3MmM0ODY5MWMiLCJuZXR3b3JrSWQiOjEwMH1d

@EresDev EresDev self-assigned this Jun 5, 2024
@EresDev EresDev marked this pull request as ready for review June 6, 2024 21:02
@EresDev EresDev requested review from 0x4007 and rndquu June 6, 2024 21:03
@rndquu
Copy link
Member

rndquu commented Jun 6, 2024

@EresDev

So if we need to deploy both static files and cloudflare pages functions we need the following github artifact structure:

github_artifact_folder
    static_html_files
        index.html
    functions

If we need to deploy only static files we need the following github artifact structure:

github_artifact_folder
    index.html

Correct? If so could you add this info to the README file for future reference.

@ubiquity ubiquity deleted a comment Jun 7, 2024
@EresDev
Copy link
Contributor Author

EresDev commented Jun 8, 2024

Correct? If so could you add this info to the README file for future reference.

You are right.

However, a better approach came into my mind today and I have re-done this today.

What was the issue with my previous submission? It worked, but it was not as clean as the new solution. output_directory parameter was being used for two different purposes. One, to extract artifact into. Second, to use it as static directory name. It was okay if the entire directory was static, but now it is confusing when we have backend functions and whole output_directory is not a static directory. The new solution introduces a new parameter statics_directory to decouple both. It also offers an opportunity to move all old and new projects to the same directory structure, while still supporting old directory structure.

I have added the info to readme, and I have also updated the QA links.
@rndquu

Copy link
Member

@0x4007 0x4007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks fine

@0x4007 0x4007 merged commit f66a14b into ubiquity:main Jun 16, 2024
@0x4007
Copy link
Member

0x4007 commented Jun 18, 2024

@EresDev doesn't seem to work anymore. Should not have to rely on a pull request. Should deploy on every commit.

https://github.com/ubiquity/pay.ubq.fi/actions/runs/9562570163/job/26359224909

I can leave it for another day or two for testing in production but otherwise will need to revert.

Please prioritize this as it affects all of our projects. Thanks.

@EresDev
Copy link
Contributor Author

EresDev commented Jun 18, 2024

@EresDev doesn't seem to work anymore. Should not have to rely on a pull request. Should deploy on every commit.

I didn't change the trigger. So whatever the trigger (commit or pull) was set before this PR, it should work. But let me take a look, maybe it is breaking somewhere.

@0x4007
Copy link
Member

0x4007 commented Jun 18, 2024

If needed, please work on the development branch directly. It might help you debug faster.

We can revert if you can't figure it out in the next day or two.

@EresDev
Copy link
Contributor Author

EresDev commented Jun 18, 2024

Please prioritize this as it affects all of our projects. Thanks.

Ok, it appears there is no issue. It is working fine.
https://github.com/ubiquity/pay.ubq.fi/actions/runs/9564115180/job/26364104059

We need to understand a tricky part to know why it failed in your case.
development branch uses artifact name: static
beta branch uses artifact name: full-stack-app

In your link, the "deploy to cloudflare" workflow was on development branch. It needed an artifact created by "build" workflow on the same branch. But the previous run of "build" workflow was "beta" branch.

If "build" workflow runs before "deploy to cloudflare" there is no issue. You probably ran "deploy to cloudflare" manually, and last "build" was done by the different branch with a different artifact name.

So, until we have gift-cards in beta branch, to build and deploy manually, first run the build workflow, and then run the deploy to cloudflare workflow.

I have also run the deploy workflow on work.ubq.fi just to be safe, and it also worked fine. https://github.com/ubiquity/work.ubq.fi/actions/runs/9477343124/job/26363140008

@EresDev
Copy link
Contributor Author

EresDev commented Jun 18, 2024

Please prioritize this as it affects all of our projects. Thanks.

Ok, it appears there is no issue. It is working fine. https://github.com/ubiquity/pay.ubq.fi/actions/runs/9564115180/job/26364104059

We need to understand a tricky part to know why it failed in your case. development branch uses artifact name: static beta branch uses artifact name: full-stack-app

In your link, the "deploy to cloudflare" workflow was on development branch. It needed an artifact created by "build" workflow on the same branch. But the previous run of "build" workflow was "beta" branch.

If "build" workflow runs before "deploy to cloudflare" there is no issue. You probably ran "deploy to cloudflare" manually, and last "build" was done by the different branch with a different artifact name.

So, until we have gift-cards in beta branch, to build and deploy manually, first run the build workflow, and then run the deploy to cloudflare workflow.

I have also run the deploy workflow on work.ubq.fi just to be safe, and it also worked fine. https://github.com/ubiquity/work.ubq.fi/actions/runs/9477343124/job/26363140008

The above info is correct if we want to deploy to development branch. The deploy of non-default branch still doesn't work. I am looking into it.
All other projects should deploy correctly despite this. Only the gift-cards PR has issues.

@EresDev
Copy link
Contributor Author

EresDev commented Jun 18, 2024

Deployment of branch beta pay.ubq.fi successfull: https://github.com/ubiquity/pay.ubq.fi/actions/runs/9568299929/job/26378171356

Deployment of branch development pay.ubq.fi successfull: https://github.com/ubiquity/pay.ubq.fi/actions/runs/9567051444/job/26377832050

Deployment of work.ubq.fi successfull: https://github.com/ubiquity/work.ubq.fi/actions/runs/9568407358

It is all working fine now. @0x4007

@0x4007
Copy link
Member

0x4007 commented Jun 18, 2024

beta.pay.ubq.fi and pay.ubq.fi resolve to the same commit @rndquu

http://alpha.beta.pay.ubq.fi/ (a made up one now for testing improperly config'd dynamic settings) does not resolve.

@rndquu
Copy link
Member

rndquu commented Jun 18, 2024

beta.pay.ubq.fi and pay.ubq.fi resolve to the same commit @rndquu

http://alpha.beta.pay.ubq.fi/ (a made up one now for testing improperly config'd dynamic settings) does not resolve.

ubiquity/pay.ubq.fi#226 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support pages functions deployment
3 participants